package co.edu.usbcali.adt.exercises.translator;

import java.io.Serializable;

public class Dictionary implements Serializable{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -5918874601190003616L;
	public static final int MAX_WORDS=100;
	public static final int LANGUAGES=2;

	private String[][] dictionary;
	private String language;
	private int size;

	public Dictionary(String language) {
		super();
		this.language = language;
		dictionary=new String[LANGUAGES][MAX_WORDS];
		size=0;
	}

	public String getLanguage() {
		return language;
	}
	public void setLanguage(String language) {
		this.language = language;
	}

	public int getSize() {
		return size;
	}

	void addWord(String wordS,String wordT){
		dictionary[0][size]=wordS;
		dictionary[1][size]=wordT;
		size++;
	}

	String tralate(String word){
		for(int i=0;i<size;i++){
			if(dictionary[0][i].equals(word)){
				return dictionary[1][i];
			}
		}
		return null;
	}

	String backTranslate(String word){
		for(int i=0;i<size;i++){
			if(dictionary[1][i].equals(word)){
				return dictionary[0][i];
			}
		}
		return null;
	}

	public String[] equivalences(int i){
		return new String[]{dictionary[0][i],dictionary[1][i]};
	}
}
